import menuConfigMap from "./menu_config";

/**
 * 根据地址栏的路径，获取admin页面header组件上显示用的title
 * @param {地址栏的路径} pathname 
 * @returns 标题字符串
 */
export function getTitle(pathname){
        let pathKey = (pathname.indexOf("product") !== -1 && pathname.indexOf("category") === -1) ? "/product" : "/" + pathname.split("/").reverse()[0];
        let title = "";
        if (pathKey === "/admin")
            title = menuConfigMap.get("/home").title;
        else
            title = menuConfigMap.get(pathKey).title;
    return title;
}